package global

import (
	"fmt"
	"log"

	"github.com/fsnotify/fsnotify"
	"github.com/spf13/viper"
)

func InitConf() {
	viper.SetConfigFile("./conf/conf.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		log.Panic("日志文件读取失败", err)
		return
	}
	viper.OnConfigChange(func(e fsnotify.Event) {
		fmt.Println("config file changed:", e.Name)
		if err = viper.Unmarshal(&GVA_CONFIG); err != nil {
			fmt.Println(err)
		}
	})
	if err = viper.Unmarshal(&GVA_CONFIG); err != nil {
		fmt.Println(err)
	}
}
